function ModuleSchool(doc, container, width, height, user, date, options) {
  this._doc = doc;
  this._container = container;
  this._width = width;
  this._height = height;
  this._user = user;
  this._date = date;
  this._options = options;

  this._createElements();
};

ModuleSchool.prototype._createElements = function() {
  this._gui = new School(this._doc, this._container, this._width, this._height, this._user, this._date, this._options)._gui;
  var popupBox = (this._options && this._options.popupBox) ? this._options.popupBox : null;
  var callbackFunc = (this._options && this._options.callbackFunc) ? this._options.callbackFunc : function() {};
  //Preset
  //Object
  var id = (this._options && this._options.id) ? this._options.id : null;
  var school = (this._options && this._options.object) ? this._options.object : pz_school.instance();
  if (!id && !school.id) {
    window.alert('ERROR: CAN NOT ADD VISA APPL!');
    return;
  }
  if (!school.id) {
    school.client_id = id;
    school.course_date_start = 0;
    school.next_payment_date = 0;
  }
  //Display
  this._gui.school_name.value = school.school_name;
  this._gui.course_name.value = school.course_name;
  this._gui.course_level.value = school.course_level;
  this._gui.course_date_start.value = (school.course_date_start == 0) ? '' : SimpleDate.format(SimpleDate.fromStamp(school.course_date_start, false), false);
  
  this._gui.amount_paid.value = school.amount_paid;
  this._gui.paper_num.value = school.paper_num;
  this._gui.english_weeks.value = school.english_weeks;
  this._gui.other_course_length.value = school.other_course_length;
  this._gui.next_payment_date.value = (school.next_payment_date == 0) ? '' : SimpleDate.format(SimpleDate.fromStamp(school.next_payment_date, false), false);

  this._gui.file_note.value = school.file_note;
  //Event
  var _self = this;
  this._gui.school_name.onchange = function() { school.school_name = this.value; };
  this._gui.course_name.onchange = function() { school.course_name = this.value; };
  this._gui.course_level.onchange = function() { school.course_level = this.value; };
  this._gui.course_date_start.onclick = function() { _self._selectDate(this, school.course_date_start, function(sd) { school.course_date_start = SimpleDate.toStamp(sd, false); }, false); };

  this._gui.amount_paid.onchange = function() { school.amount_paid = this.value; };
  this._gui.paper_num.onchange = function() { school.paper_num = this.value; };
  this._gui.english_weeks.onchange = function() { school.english_weeks = this.value; };
  this._gui.other_course_length.onchange = function() { school.other_course_length = this.value; };
  this._gui.next_payment_date.onclick = function() { _self._selectDate(this, school.next_payment_date, function(sd) { school.next_payment_date = SimpleDate.toStamp(sd, false); }, false); };

  this._gui.file_note.onchange = function() { school.file_note = this.value; };
  //Submit
  this._gui.save.onclick = function() { new RequestUtils()._write(JSON.stringify([{ n: 'pz_school', a: [school], r: [] }]), function(result, params) { popupBox._close(); callbackFunc(); }, { pos: DOMUtils.findPos(this) });
                                      };
  this._gui.cancel.onclick = function() { popupBox._close(); };
};

ModuleSchool.prototype._selectDate = function(display, date, callbackFunc, showTime) {
  var div = document.createElement('div');
  var ds = new DateSelect((date == 0) ? null : SimpleDate.fromStamp(date, false), null, { container: div, showTime: showTime });
  ds._selectFunc = function(sd) { callbackFunc(sd);
                                  if (sd) { 
                                    display.value = SimpleDate.format(sd, showTime);
                                  } else {
                                    display.value = '';
                                  }
                                  popupBox._close();
                                };
  
  var popupBox = new ModulePopupBoxSimple();
  var pos = DOMUtils.findPos(display);
  popupBox._open(div, { pos: [pos[0], pos[1] + 85] });
};